
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.paginators import MyPage
from meiduo_admin.serializers.admin_serializers import *


# 新建管理员可选分组视图
class AdminUserGroupListView(ListAPIView):
    queryset = Group.objects.all()
    serializer_class = AdminUserGroupSerializer
    pagination_class = None


from rest_framework.exceptions import PermissionDenied
# 管理员用户视图集
class AdminUserViewSet(ModelViewSet):

    queryset = User.objects.filter(is_staff=True)
    serializer_class = AdminUserModelSerializer
    pagination_class = MyPage


    # 针对视图集，如何检查权限？！
    # 答：drf框架中权限检查由谁来做？！
    # def check_permissions(self, request):
    #     user = request.user
    #     if not user.is_superuser:
    #         raise PermissionDenied('您不是超级管理员，无法操作管理员增删改查')

    # 获取权限检查后端类对象
    # def get_permissions(self):
    #     pass






